package test;

import dao.UserMapper;
import entity.User;
import org.apache.ibatis.session.SqlSession;
import org.apache.log4j.Logger;
import org.junit.Test;
import utils.MyBatisUtil;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

public class BianMa {

    private Logger logger=Logger.getLogger(UserTest.class);

    @Test
    public void testGetUserList(){
        SqlSession sqlSession=null;
        List<User> userList=new ArrayList<>();
        List<User> userList1=new ArrayList<>();
        try{
            sqlSession= MyBatisUtil.createSqlSession();
            String userName="";
            Integer pageSize=5;
            Integer currentPageNo=0;
            userList=sqlSession.getMapper(UserMapper.class).getUserBianMa(userName,currentPageNo,pageSize);
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            MyBatisUtil.closeSqlSession(sqlSession);
        }
        logger.debug("testGetUserList.size========> id:"+userList.size());
        for (User use:userList){
            logger.debug("testGetUserList======>id:"+use.getId()+" and userCode:"+use.getUserCode()+
                    " and userName:"+use.getUserName()+" and userRole:"+use.getUserRole()+
                    " and creationDate:"+new SimpleDateFormat("yyyy-MM-dd").format(use.getCreationDate()));
        }

    }
}
